﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Root2 : System.Web.UI.MasterPage
{
    TiemPhongDataContext db = new TiemPhongDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["DangNhap"] == null)
        {
            lbChao.Visible = false;
            lbThongtin.Visible = false;
            lbThoat.Visible = false;
            lbDangky.Visible = true;
            lbDangNhap.Visible = true;
            lba.Visible = true;
        }
        else
        {
            NguoiDung Customer = db.NguoiDungs.SingleOrDefault(c => c.NguoiDungId.ToString() == Session["DangNhap"]);
            if (Customer != null)
            {
                lbChao.Visible = true;
                lbThongtin.Visible = true;
                lbThoat.Visible = true;
                lbDangky.Visible = false;
                lbDangNhap.Visible = false;
                lba.Visible = false;
                lbChao.Text = "Xin chào: <strong>" + Customer.Email + "<font color=" + "#666666" + ">|</font></strong>";
            }
        }
    }
    protected void btThoat_Click(object sender, EventArgs e)
    {
        Session["DangNhap"] = null;
        lbChao.Visible = false;
        lbThoat.Visible = false;
        lbThongtin.Visible = false;
        lbDangky.Visible = true;
        lbDangNhap.Visible = true;
        lba.Visible = true;
        Response.Redirect(Request.Url.AbsolutePath);

    }
    protected void lbtThongTinTK_Click(object sender, EventArgs e)
    {
        Response.Redirect("ThongTinTaiKhoan.aspx");
    }
    protected void lbtDangNhap_Click(object sender, EventArgs e)
    {
        Session["page"] = Request.Url.AbsolutePath;
        Response.Redirect("DangNhap.aspx");
    }
    protected void lbtDangKy_Click(object sender, EventArgs e)
    {
        Response.Redirect("DangKy.aspx");
    }
}
